package org.lysh.enums;

import org.lysh.exception.BusinessException;

/**
 * @author liyishan
 * @date 2024/4/24 16:13
 * @apiNote
 */

public enum HttpContentTypeEnum {
    AVI(".avi", "video/avi", "AVI"),
    BMP(".bmp", "application/x-bmp", "BMP"),
    ICO(".ico", "application/x-ico", "ICO"),
    JPE(".jpe", "image/jpeg", "JPE"),
    JPEG(".jpeg", "image/jpg", "JPEG"),
    JPG(".jpg", "image/jpg", "JPG"),
    PNG(".png", "image/jpg", "PNG"),
    DOC(".doc", "application/msword", "DOC"),
    DOCX(".docx", "application/vnd.ms-word.document.12", "DOCX"),
    MP4(".mp4", "video/mpeg4", "MP4"),
    M4A(".m4a", "audio/mp4", "M4A"),
    MP3(".mp3", "audio/mp3", "MP3"),
    XLS(".xls", "application/x-xls", "XLS"),
    XLSX(".xlsx", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", "XLSX"),
    ZIP(".zip", "application/x-zip-compressed", "ZIP"),
    RAR(".rar", "application/octet-stream", "RAR"),
    PDF(".pdf", "application/pdf", "PDF"),
    TXT(".txt", "text/plain", "TXT"),
    WAV(".wav", "audio/x-wav", "WAV"),
    PPT(".ppt", "application/vnd.ms-powerpoint", "PPT"),
    PPTX(".pptx", "application/vnd.openxmlformats-officedocument.presentationml.presentation", "PPTX");

    private String suffix;
    private String contentType;
    private String fileType;

    public static HttpContentTypeEnum parse(String suffix) {
        HttpContentTypeEnum[] var1 = values();
        int var2 = var1.length;

        for(int var3 = 0; var3 < var2; ++var3) {
            HttpContentTypeEnum item = var1[var3];
            if (item.getSuffix().equalsIgnoreCase(suffix)) {
                return item;
            }
        }

        throw new BusinessException("解析文件ContentType失败");
    }

    public String getSuffix() {
        return this.suffix;
    }

    public String getContentType() {
        return this.contentType;
    }

    public String getFileType() {
        return this.fileType;
    }

    private HttpContentTypeEnum(String suffix, String contentType, String fileType) {
        this.suffix = suffix;
        this.contentType = contentType;
        this.fileType = fileType;
    }
}
